ig.module(
    
    'game.entities.target'
    
).requires(
    
    'impact.entity'
    
).defines(function(){

    EntityTarget = ig.Entity.extend({
        size:{
            x: 3,
            y: 3
        },
        offset:{
            x: 0,
            y: 0
        },
        maxVel: {
            x: 100,
            y: 100
        },
        
        player: null,
        
        cursor: null,
        
        distance: 20,
        
        checkAgainst: ig.Entity.TYPE.NONE,
        health: 1,
        animSheet: new ig.AnimationSheet('media/sprites/factory.png',4,4),
        init: function( x, y, settings){
            this.parent(x, y, settings);
            this.addAnim('idle', 1, [0]);
        },
        update: function(){
            var cords = this.getRelCords();
            this.pos.x = this.player.pos.x + this.player.size.x/2 + cords[0];
            this.pos.y = this.player.pos.y + this.player.size.y/2 + cords[1];
            this.parent();
        },
        getRelCords: function(){
            var dt = this.player.distanceTo(this.cursor);
            
            var cf = (dt < this.player.size.x ? this.player.size.x : dt) / this.distance;
            return [-(this.cursor.pos.x - this.player.pos.x)/cf,
                    -(this.cursor.pos.y - this.player.pos.y)/cf];
        }
    });
})